;;; Copyright (c) 1999 Massachusetts Institute of Technology
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, see https://gnu.org/licenses or
;;; write to:
;;;  Free Software Foundatiom, Inc.
;;;  51 Franklin St, Fifth Floor
;;;  Boston, MA 02110-1301
;;;  USA

.AUXIL

IFNDEF DEFSYM,[	;ALLOW USER TO USE SYMBOLS IN OTHER WAYS IF HE WISHES.
		;BUT NORMALLY, DEFSYM FOO==BAR DOES FOO==BAR WITH ERROR CHECK.
DEFINE DEFSYM X/
IRPS Z,,[X]
IFNDEF Z,X
.ELSE [
   $$TEM1==Z
   X
   IFN Z-$$TEM1,.ERR Z MULTIPLY .QUOTE`.QUOTE/DEFINED/`
]
.ISTOP
TERMIN TERMIN

IFLE .MLLIT,.ERR .MLLIT MUST BE 1; SETTING IT TO 1.
.MLLIT==1
$$TEMP==1
]
.ELSE $$TEMP==0

;FILE SYSTEM PARAMETERS - APPLIES TO ALL ITS MACHINES

;9/5/79 - tut format changed!
;8/19/90 - DM "funny" bit flushed

;MFD INFO

IFDEF NBLKS,[			;MFDBLK KNOWN ONLY IF .INSRT APPROPRIATE PHYSICAL PARAMS FILE
DEFSYM	MFDBLK==NBLKS/2-1	;LOC ON DISK
DEFSYM	MFDCYL==MFDBLK/NBLKSC
DEFSYM	MFDSRF==<MFDBLK-MFDCYL*NBLKSC>*SECBLK/NSECS
DEFSYM	MFDSEC==<MFDBLK-MFDCYL*NBLKSC>*SECBLK-MFDSRF*NSECS
]
		;RANDOM INFO IN MFD
DEFSYM	MDNUM==0	;ASCENDING DIR NUM
DEFSYM	MDNAMP==1	;PNTR TO ORG OF USER NAME BLOCK AREA
DEFSYM	MDYEAR==2	;CURRENT YEAR
DEFSYM	MPDOFF==3	;DE-CORIOLIS CLOCK OFFSET
DEFSYM	MPDWDK==4	;PREFERRED WRITING DISK (PHYSICAL DRIVE #)
DEFSYM	MDCHK==5	;THIS WORD MUST BE M.F.D. (FOR CHECKING)
DEFSYM	MDNUDS==6	;NUMBER USER DIRECTORIES (FOR CHECKING ONLY)
DEFSYM	LMIBLK==7	;TOTAL STG USED BY HACKS LIKE THIS
		;USER NAME BLKS FROM C(MDNAMP) TO END
DEFSYM	LMNBLK==2	;# WDS/BLK
DEFSYM	MNUNAM==0	;6BIT USER NAME
 ;SECOND WORD OF A USER-NAME BLOCK IS ZERO.
 ;DECUUO CONTAINS A KLUDGE WHICH DEPENDS ON THIS,
 ;PLEASE NOTIFY BUG-DECUUO BEFORE CHANGING IT.

;TUT INFO

IFDEF NBLKS,[
DEFSYM	TUTBLK==MFDBLK-NTUTBL	;LOC ON DISK
DEFSYM	TUTCYL==TUTBLK/NBLKSC
DEFSYM	TUTSRF==<TUTBLK-TUTCYL*NBLKSC>*SECBLK/NSECS
DEFSYM	TUTSEC==<TUTBLK-TUTCYL*NBLKSC>*SECBLK-TUTSRF*NSECS
]
DEFSYM	TUTBYT==3		;SIZE OF BYTES (USED TO BE 4)
DEFSYM	TUTBP==<440000+TUTBYT_6>,,
DEFSYM	TUTEPW==36./TUTBYT	;NUMBER OF ENTRIES PER WORD
DEFSYM	TUTMAX==1_TUTBYT
DEFSYM	TUTLK==TUTMAX-1		;HIGHEST CODE MEANS LOCKED OUT
DEFSYM	TUTMNY==TUTLK-1		;TUT MANY OR MORE REFS

;RANDOM INFO IN TUT (AT THE FRONT)
DEFSYM	QPKNUM==0		;PACK #
DEFSYM	QPAKID==1		;PACK ID
DEFSYM	QTUTP==2		;FREE SPACE POINTER TO TRACK AREA.  ADVANCE BY CYLINDERS
DEFSYM	QSWAPA==3		;SWAPPING AREA.  FIRST TRACK OF NON-SWAPPING AREA
				;NEW FILES WILL NOT BE WRITTEN LOWER THAN THIS.
DEFSYM	QFRSTB==4		;FIRST BLOCK TUT'ED
DEFSYM	QLASTB==5		;LAST BLOCK TUT'ED
DEFSYM	QTRSRV==6		;-1 IF ONLY ALLOCATED DIRS CAN HAVE FILES ON THIS PACK
				;IF NOT 0 AND NOT -1, SIXBIT NAME OF "SECONDARY" PACK
				;STG FOR RANDOM INFO ^
DEFSYM	LTIBLK==20		;BYTES MAPPING THE DISK START HERE

;UFD INFO
;IF A IS RELATIVE LOCATION OF MFD ENTRY, USER DIR IS LOCATED IN
;TRACK NUMBERED <A-2000+2*MDNUDS>/2  (SEE QFL2)

DEFSYM	UFDBYT==6		;SIZE OF BYTES (Do not change!)
DEFSYM	UFDBPW==36./UFDBYT	;NUMBER OF BYTES PER WORD

		;RANDOM INFO IN UFD
DEFSYM	UDESCP==0	;FS PNTR TO DESC AREA
DEFSYM	UDNAMP==1	;PNTR TO ORG OF NAME AREA
DEFSYM	UDNAME==2	;USER NAME (FOR CHECKING)
DEFSYM  UDBLKS==3       ;LEFT HALF HAS AMOUNT OF SPACE ALLOCATED (NOT USED
		        ; CURRENTLY BY SYSTEM), RIGHT HALF HAS NUMBER OF BLOCKS USED.
DEFSYM  UDALLO==4       ;IF NONZERO, LEFT HALF HAS DISK NUMBER, RIGHT
		        ; HALF HAS AMOUNT OF SPACE ALLOCATED
DEFSYM	UDDESC==11.	;FIRST LOC AVAIL FOR DESC

; 8/19/90 Due to the larger size of RP07s it was necessary to officially
; flush the DM "funny" bit.  This change only changes the comments in this
; file, but any program that interprets UFD descriptors needs to be fixed
; to not mask that bit out (as most of them currently do).  Fortunately all
; the known ITS filesystems have zeros in all their "funny" bits, so the
; change is upward compatible.

; UFD descriptor format described:
;
; Each 6-bit byte is taken in turn and used to compute a sequence of block
; numbers.  If N is the current descriptor byte, and B is the current block
; number (initially undefined), then N is interpreted as follows: 
;
;  0  Marks the end of the file description.
; 
;  1 to UDTKMX  (1 to 14)		"Take" N blocks.
;	Blocks B through B + N - 1 are the next N blocks of the file.
;	Set B := B + N .
; 
;  UDTKMX+1 to UDWPH-1  (15 to 36)	"Skip" B - UDTKMX blocks.
;	Set N := N + B - UDTKMX .
;	(ITS has been broken for years such that it never uses this
;	UFD descriptor code!)
; 
;  UDWPH  (37)				Write Place Holder
;	A noop.  Used to reserve space in directories for files that are
;	being written.  Just skip over it and read the next byte.
; 
;  40 - 77				Load address and take 1.
;	Read the next NXLBYT descriptor bytes (NXLBYT=2), N2 and N3.
;	Set B := LSH(AND(N, 37), 12.) + LSH(N2, 6) + N3 .
;	Block B is the next block in the file.
;	Set B := B + 1 .
;
; A zero length file is described as two bytes: UDWPH then 0.  UDWPH does
; not otherwise normally appear in UFD descriptions for closed files.
; Note that a legal description must use codes 40 - 77 before it can use
; any code other than UDWPH.

; Links are described as a sequence of SIXBIT characters terminated with a
; 0 byte.  The directory, first and second name are stored in order.
; The first two components are terminated with a ";" if they are less than
; 6 characters long.  ";" (73), ":" (72) and " " (0) are quoted by
; preceding them with a ":".  Some examples:
;
; Link target names:		Bytes stored in directory:
;
; 123456 123456 123456		"123456123456123456 "
; ALAN   FOO    BAR		"ALAN;FOO;BAR "
; .MAIL. NAMES  >		".MAIL.NAMES;> "
; .MAIL.  LISTS   MSGS		".MAIL.: LISTS: : MSGS "
; MOON   LUNAR  :EJ		"MOON;LUNAR;::EJ "
;
; There are a lot of illegal or wasteful possibilities for link descriptors
; ("A;B ", "A;B;C;D ", ":A;:B;:C ", etc.), which is suprising since
; somebody was clearly trying to compress them into as few bytes as
; possible.

; Here is the pre 8/19/90 comment describing UFD descriptors:
; 
; 	;UFD DESCRIPTORS
; 	;0 => FREE  1-UDTKMX => TAKE NEXT N
; 	;UDTKMX+1 THRU UDWPH-1 => SKIP N-UDTKMX AND TAKE ONE
; 	;UDWPH => WRITE-PLACE-HOLDER
; 	;40 BIT SET => LOAD ADDRESS.  LOWER 5 BITS PLUS NEXT NXLBYT (2)
; 	;  CHARS (17 BITS IN ALL)
; 	;40 BIT & 20 BIT => "FUNNY" BLOCK IF DMDSK.  WHAT IS THIS, ANYWAY?
; 	;END BY 0
; 
; 	;IF LINK DESCR
; 	;6 CHAR OR UNTIL ; = SYS NAME.  MUST HAVE NO CHAR = 0 IN THIS OR
; 	; NEXT 2 NAMES 
; 	;NEXT CHAR QUOTED BY : (FOR NAMES WITH : OR ;)
; 	;NEXT CHAR N1
; 	;NEXT CHAR N2
; 	;END BY 0

DEFSYM	UDTKMX==12.		;HIGHEST "TAKE N" CODE
DEFSYM	UDWPH==31.		;PLACE HOLDER ON WRITE (OR NULL FILE)
DEFSYM	UDSKMX==UDWPH-UDTKMX-1	;# BLOCKS THAT CAN BE SKIPPED
DEFSYM	NXLBYT==2		;# ADDITIONAL BYTES FOR LOAD ADDR
				;IN SYSTEM THIS IS DEFINED AT FRONT OF FILE

	;NAME AREA DATA

DEFSYM	LUNBLK==5	;WDS/NAME BLK
DEFSYM	UNFN1==0	;FIRST FN
DEFSYM	UNFN2==1	;SECOND FN
DEFSYM	UNRNDM==2	;ALL KINDS OF RANDOM INFO
DEFSYM		UNDSCP==1500,,		;PNTR TO DESC
DEFSYM		UNPKN==150500,,		;PACK #
DEFSYM		UNLINK==1		;LINK BIT
DEFSYM		UNLNKB==220100,,
DEFSYM		UNREAP==2		;IF 1, DONT REAP FILE
DEFSYM		UNWRIT==4		;OPEN FOR WRITING
DEFSYM		UNMARK==10		;GC MARK BIT
DEFSYM		UNCDEL==20		;DEL WHEN CLOSED
DEFSYM		DELBTS==20		;DELETED -- IGNORE
DEFSYM		UNIGFL==24		;BITS TO IGNORE FILE
DEFSYM		UNWRDC==301200,,	;WORD COUNT OF LAST BLOCK MOD 2000
DEFSYM		UNDUMP==400000		;HAS BEEN DUMPED
DEFSYM	UNDATE==3	;DATE ETC.
DEFSYM		UNTIM==2200,,		;COMPACTED TIME OF CREATION
DEFSYM		UNYMD==222000,,		;Y,M,D OF CREATION
DEFSYM		UNMON==270400,,		;MONTH
DEFSYM		UNDAY==220500,,		;DAY
DEFSYM		UNYRB==330700,,		;YEAR
DEFSYM	UNREF==4	;REFERENCE DATE SAME AS LEFT HALF OF UNDATE
DEFSYM		UNREFD==222000,,	;REFERENCE DATE BYTE POINTER
DEFSYM		UNAUTH==111100,,	;MFD INDEX OF AUTHOR, ALL 1=> NO DIRECTORY
DEFSYM		UNBYTE==001100,,	;FILE BYTE SIZE AND LENGTH INFO.
			;LET S=BITS PER BYTE, C=COUNT OF UNUSED BYTES IN LAST WD
			;400+100xS+C	S=1 TO 3	C=0 TO 35.
			;200+20xS+C	S=4 TO 7	C=0 TO 8
			;44+4xS+C	S=8 TO 18.	C=0 TO 3
			;44-S		S=19. TO 36.	C=0
			;NOTE THAT OLD FILES HAVE UNBYTE=0 => S=36.

IF1 IFDEF NUDSL, IFG NUDSL*LMNBLK+LMIBLK-2000,.ERR MFD LOSES

IFN $$TEMP,EXPUNG DEFSYM
